package com.sunshine_brid.ccras_server.service.dao;

import static com.sunshine_brid.ccras_server.service.support.NoteDynamicSqlSupport.*;
import static org.mybatis.dynamic.sql.SqlBuilder.isEqualTo;

import com.sunshine_brid.ccras_server.service.entity.Note;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.BasicColumn;
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
import org.mybatis.dynamic.sql.update.UpdateModel;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import org.mybatis.dynamic.sql.util.mybatis3.CommonCountMapper;
import org.mybatis.dynamic.sql.util.mybatis3.CommonDeleteMapper;
import org.mybatis.dynamic.sql.util.mybatis3.CommonInsertMapper;
import org.mybatis.dynamic.sql.util.mybatis3.CommonUpdateMapper;
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;

@Mapper
public interface NoteMapper extends CommonCountMapper, CommonDeleteMapper, CommonInsertMapper<Note>, CommonUpdateMapper {
    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    BasicColumn[] selectList = BasicColumn.columnList(id, entityId, pointId, type, algorithmId, equipmentId, assessment, status, createTime, updateTime, content);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="NoteResult", value = {
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="entity_id", property="entityId", jdbcType=JdbcType.INTEGER),
        @Result(column="point_id", property="pointId", jdbcType=JdbcType.INTEGER),
        @Result(column="type", property="type", jdbcType=JdbcType.TINYINT),
        @Result(column="algorithm_id", property="algorithmId", jdbcType=JdbcType.INTEGER),
        @Result(column="equipment_id", property="equipmentId", jdbcType=JdbcType.INTEGER),
        @Result(column="assessment", property="assessment", jdbcType=JdbcType.INTEGER),
        @Result(column="status", property="status", jdbcType=JdbcType.TINYINT),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="content", property="content", jdbcType=JdbcType.LONGVARCHAR)
    })
    List<Note> selectMany(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("NoteResult")
    Optional<Note> selectOne(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default long count(CountDSLCompleter completer) {
        return MyBatis3Utils.countFrom(this::count, note, completer);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int delete(DeleteDSLCompleter completer) {
        return MyBatis3Utils.deleteFrom(this::delete, note, completer);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int deleteByPrimaryKey(Integer id_) {
        return delete(c -> 
            c.where(id, isEqualTo(id_))
        );
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insert(Note row) {
        return MyBatis3Utils.insert(this::insert, row, note, c ->
            c.map(id).toProperty("id")
            .map(entityId).toProperty("entityId")
            .map(pointId).toProperty("pointId")
            .map(type).toProperty("type")
            .map(algorithmId).toProperty("algorithmId")
            .map(equipmentId).toProperty("equipmentId")
            .map(assessment).toProperty("assessment")
            .map(status).toProperty("status")
            .map(createTime).toProperty("createTime")
            .map(updateTime).toProperty("updateTime")
            .map(content).toProperty("content")
        );
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insertMultiple(Collection<Note> records) {
        return MyBatis3Utils.insertMultiple(this::insertMultiple, records, note, c ->
            c.map(id).toProperty("id")
            .map(entityId).toProperty("entityId")
            .map(pointId).toProperty("pointId")
            .map(type).toProperty("type")
            .map(algorithmId).toProperty("algorithmId")
            .map(equipmentId).toProperty("equipmentId")
            .map(assessment).toProperty("assessment")
            .map(status).toProperty("status")
            .map(createTime).toProperty("createTime")
            .map(updateTime).toProperty("updateTime")
            .map(content).toProperty("content")
        );
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insertSelective(Note row) {
        return MyBatis3Utils.insert(this::insert, row, note, c ->
            c.map(id).toPropertyWhenPresent("id", row::getId)
            .map(entityId).toPropertyWhenPresent("entityId", row::getEntityId)
            .map(pointId).toPropertyWhenPresent("pointId", row::getPointId)
            .map(type).toPropertyWhenPresent("type", row::getType)
            .map(algorithmId).toPropertyWhenPresent("algorithmId", row::getAlgorithmId)
            .map(equipmentId).toPropertyWhenPresent("equipmentId", row::getEquipmentId)
            .map(assessment).toPropertyWhenPresent("assessment", row::getAssessment)
            .map(status).toPropertyWhenPresent("status", row::getStatus)
            .map(createTime).toPropertyWhenPresent("createTime", row::getCreateTime)
            .map(updateTime).toPropertyWhenPresent("updateTime", row::getUpdateTime)
            .map(content).toPropertyWhenPresent("content", row::getContent)
        );
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default Optional<Note> selectOne(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectOne(this::selectOne, selectList, note, completer);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default List<Note> select(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectList(this::selectMany, selectList, note, completer);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default List<Note> selectDistinct(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectDistinct(this::selectMany, selectList, note, completer);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default Optional<Note> selectByPrimaryKey(Integer id_) {
        return selectOne(c ->
            c.where(id, isEqualTo(id_))
        );
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int update(UpdateDSLCompleter completer) {
        return MyBatis3Utils.update(this::update, note, completer);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    static UpdateDSL<UpdateModel> updateAllColumns(Note row, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(id).equalTo(row::getId)
                .set(entityId).equalTo(row::getEntityId)
                .set(pointId).equalTo(row::getPointId)
                .set(type).equalTo(row::getType)
                .set(algorithmId).equalTo(row::getAlgorithmId)
                .set(equipmentId).equalTo(row::getEquipmentId)
                .set(assessment).equalTo(row::getAssessment)
                .set(status).equalTo(row::getStatus)
                .set(createTime).equalTo(row::getCreateTime)
                .set(updateTime).equalTo(row::getUpdateTime)
                .set(content).equalTo(row::getContent);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(Note row, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(id).equalToWhenPresent(row::getId)
                .set(entityId).equalToWhenPresent(row::getEntityId)
                .set(pointId).equalToWhenPresent(row::getPointId)
                .set(type).equalToWhenPresent(row::getType)
                .set(algorithmId).equalToWhenPresent(row::getAlgorithmId)
                .set(equipmentId).equalToWhenPresent(row::getEquipmentId)
                .set(assessment).equalToWhenPresent(row::getAssessment)
                .set(status).equalToWhenPresent(row::getStatus)
                .set(createTime).equalToWhenPresent(row::getCreateTime)
                .set(updateTime).equalToWhenPresent(row::getUpdateTime)
                .set(content).equalToWhenPresent(row::getContent);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int updateByPrimaryKey(Note row) {
        return update(c ->
            c.set(entityId).equalTo(row::getEntityId)
            .set(pointId).equalTo(row::getPointId)
            .set(type).equalTo(row::getType)
            .set(algorithmId).equalTo(row::getAlgorithmId)
            .set(equipmentId).equalTo(row::getEquipmentId)
            .set(assessment).equalTo(row::getAssessment)
            .set(status).equalTo(row::getStatus)
            .set(createTime).equalTo(row::getCreateTime)
            .set(updateTime).equalTo(row::getUpdateTime)
            .set(content).equalTo(row::getContent)
            .where(id, isEqualTo(row::getId))
        );
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int updateByPrimaryKeySelective(Note row) {
        return update(c ->
            c.set(entityId).equalToWhenPresent(row::getEntityId)
            .set(pointId).equalToWhenPresent(row::getPointId)
            .set(type).equalToWhenPresent(row::getType)
            .set(algorithmId).equalToWhenPresent(row::getAlgorithmId)
            .set(equipmentId).equalToWhenPresent(row::getEquipmentId)
            .set(assessment).equalToWhenPresent(row::getAssessment)
            .set(status).equalToWhenPresent(row::getStatus)
            .set(createTime).equalToWhenPresent(row::getCreateTime)
            .set(updateTime).equalToWhenPresent(row::getUpdateTime)
            .set(content).equalToWhenPresent(row::getContent)
            .where(id, isEqualTo(row::getId))
        );
    }
}